<?php
$GLOBALS['jscripts'][] = '/js/tabs.js';
$modules = $CONFIG['modules'];
$c = Eleanor::$Cache->Get('first_page_right'. Language::$main . $modules[0]);
if ($c === false) {
	global $Eleanor;
	$qr = $R = Eleanor::$Db->Query('
		SELECT `id`, `title_l`, `active`, `sections`, `path`
		FROM `'. P .'modules`
		WHERE `id` = '.( implode(' OR `id` = ', $modules) ).'
		ORDER BY `id`
	');
	$lang = Eleanor::$Language->load(Eleanor::$rootf .'langs/first_page_right-*.php');
	$c = '<div id="content_right_bookmarks_container">';
	$cm = $cl = $cg = '';
	$i = 0;
	while($a = $qr->fetch_assoc()) {
		$conf = include $Eleanor::FormatPath($a['path'] .'/config.php');

		if (isset($conf['t'], $conf['tl'])) {
			$section = array_keys(unserialize($a['sections']));
			$section = $section[0];
			$section_inf = unserialize($a['sections']);
			$section_name = Eleanor::FilterLangValues($section_inf[$conf['n']]);
			$section_name = $section_name[0];
			unset($section_inf);
			$cm .= '<a href="#" data-rel="'. $section .'"><div class="content_right_bookmark">'. Eleanor::FilterLangValues(unserialize($a['title_l'])) .'</div></a>';
            if ($conf['tl'] == 'el_news_l') {
                $text = '`announcement` AS `text`';
            } else {
                $text = '`text`';
            }
			$m_data = Eleanor::$Db->Query('
				SELECT `id`, `cats`, `uri`, `title`, '. $text .'
				FROM `'. $conf['t'] .'`
				INNER JOIN `'. $conf['tl'] .'` USING(`id`)
				WHERE `language`IN("", "'. Language::$main. '") AND `lstatus` = 1
				ORDER BY `ldate` DESC
				LIMIT 3
			');
			$cg .= '<div class="content_right_records_container" id="'. $section .'" style="display: none">';

			while($m = $m_data->fetch_assoc()) {
				$cl .= '<a href="'. $Eleanor->Url->Construct(array('module' => $section_name) + $Eleanor->Categories->GetUri((int)ltrim($m['cats'],',')) + array('u' => array($m['uri'], 'nid' => $m['id'])), false, true, 1) .'" title="'. $m['title'] .'">
				<article class="content_right_record">
					<img src="'. Eleanor::GetTemplatePath() .'images/bmw.png" width="129" height="95" alt="">
					<div class="content_right_upper">'. $m['title'] .'</div>
					<div class="content_right_lower">'. Strings::CutStr(strip_tags($m['text']), 190) .'</div>
				</article>
				</a>';
			}
			$cg .= $cl .'<div class="read_further_container right_read_further">
			<a href="'. $Eleanor->Url->special . $Eleanor->Url->Construct(array('module' => $section_name), false) .'"><div class="read_further_image"></div>
			<div class="read_further_text">'. $lang['read_more'] .'</div></a>
			</div></div>';
			$cl = '';
		}
	}
	$c .= $cm .'</div>'. $cg;
	Eleanor::$Cache->Put('first_page_right'. Language::$main . $modules[0], $c);
}
return $c;